﻿using System;
using System.Collections.Generic;
using System.Globalization;
using Bricks;

namespace Motar
{
    
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="TResolver"></typeparam>
    public abstract class LocaleResolverFacadeBase<TResolver> : FacadeBase<TResolver>, ILocaleResolverFacade<TResolver>
    {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="resolver"></param>
        protected LocaleResolverFacadeBase(TResolver resolver) :
            base(() => resolver)
        {
            if (resolver == null)
            {
                throw new ArgumentNullException("resolver");
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public abstract ICollection<string> Locales { get; }

        /// <summary>
        /// 
        /// </summary>
        public abstract string DefaultLocale { get; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public abstract ILocaleResolverFacade Register(string key, CultureInfo culture);

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public CultureInfo Resolve()
        {
            return Resolve(DefaultLocale);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public abstract CultureInfo Resolve(string key);
    }
}
